package ao.ai.ml.demo.supervised.classification.plane;

import ao.ai.ml.algo.supervised.model.example.ext.BinaryClassificationExample;
import ao.ai.ml.model.feature_set.ext.cat.bin.SingleBinaryFeature;
import ao.ai.ml.model.feature_set.ext.num.NumericalFeatureList;
import ao.ai.ml.model.feature_set.impl.BinaryScalar;
import ao.ai.ml.model.feature_set.impl.FeatureVector;
import ao.ai.ml.model.feature_type.FeatureType;
import ao.ai.ml.model.feature_type.ext.MutableFeatureSet;
import ao.ai.ml.model.feature_type.impl.FeatureTypeImpl;
import ao.ai.ml.model.feature_type.impl.FeatureTypeSetImpl;

/**
 * User: aostrovsky
 * Date: 6-Feb-2010
 * Time: 12:25:58 AM
 */
public class XyBinaryExample
        implements BinaryClassificationExample
{
    //--------------------------------------------------------------------
    private static final FeatureType X_TYPE = new FeatureTypeImpl("x");
    private static final FeatureType Y_TYPE = new FeatureTypeImpl("y");

    private static final MutableFeatureSet INPUT_FEATURES;
    static
    {
        INPUT_FEATURES = new FeatureTypeSetImpl();
        INPUT_FEATURES.add( X_TYPE );
        INPUT_FEATURES.add( Y_TYPE );
    }

    private static final FeatureType CLASS_TYPE =
            new FeatureTypeImpl("positive");


    //--------------------------------------------------------------------
    private final int     x;
    private final int     y;
    private final boolean isPositive;


    //--------------------------------------------------------------------
    public XyBinaryExample(
            int     xCoordinate,
            int     yCoordinate,
            boolean valueIsPositive)
    {
        x          = xCoordinate;
        y          = yCoordinate;
        isPositive = valueIsPositive;
    }


    //--------------------------------------------------------------------
    @Override
    public NumericalFeatureList input()
    {
        return new FeatureVector(
                INPUT_FEATURES, x, y);
    }

    @Override
    public SingleBinaryFeature output()
    {
        return new BinaryScalar(
                isPositive, CLASS_TYPE);
    }


    //--------------------------------------------------------------------
    @Override
    public String toString()
    {
        return "[" + x + "," + y + "] -> " + isPositive;
    }
}